const {
    Mysql
} = require('../tools/utils');
const {
    checkOrder
} = require('../tools/checkOrder');
module.exports = async ctx => {
    let {
        uid,
        vid,
        money,
        orderId
    } = ctx.request.body;

    try {
        let res = await checkOrder(orderId);
        if (res.trade_state == 'SUCCESS') {
            let sql = `INSERT INTO orderList(uid,vid,orderId,money,type) VALUES(${uid},${vid},'${orderId}',${money},'ADMIRE')`;
            await Mysql(sql);
            ctx.state.data = {
                code: '001'
            }
        }
    } catch (error) {
        ctx.state.data = {
            code: '002'
        }
    }
};